sysroot: Avoid double cleanup, and ensure no cleanup if specified
authorColin Walters <walters@verbum.org>
Thu, 8 Sep 2016 17:38:08 +0000 (13:38 -0400)
committerAtomic Bot <atomic-devel@projectatomic.io>
Thu, 8 Sep 2016 20:42:09 +0000 (20:42 +0000)
Since forever, we've been doing two cleanups.  In
https://github.com/ostreedev/ostree/commit/8ece4d6d51bdbe3e41ab318259276bb83e553aa0
I thought we were doing just one and wanted to go to zero (if specified),
but I actually just dropped one cleanup.

In https://github.com/projectatomic/rpm-ostree/pull/452
@jlebon pointed out the duplication.  Fix this by creating a new internal
deploy wrapper that takes cleanup flags.

(Since we already had the "piecemeal cleanup" API internally, let's
 frame it in terms of that, rather than passing down a boolean).

Closes: #500
Approved by: jlebon

src/libostree/ostree-sysroot-deploy.c
src/libostree/ostree-sysroot-private.h
src/libostree/ostree-sysroot.c

index a05ca30ded564f8f2d1af805fff5f7fd22cc76d8..a49428d28e994b3f9fa16f01c9bf695bbfd047a9 100644 (file)
@@ -1712,6 +1712,18 @@ ostree_sysroot_write_deployments (OstreeSysroot     *self,
                                   GPtrArray         *new_deployments,
                                   GCancellable      *cancellable,
                                   GError           **error)
+{
+  return _ostree_sysroot_write_deployments_internal (self, new_deployments,
+                                                     OSTREE_SYSROOT_CLEANUP_ALL,
+                                                     cancellable, error);
+}
+
+gboolean
+_ostree_sysroot_write_deployments_internal (OstreeSysroot     *self,
+                                            GPtrArray         *new_deployments,
+                                            OstreeSysrootCleanupFlags cleanup_flags,
+                                            GCancellable      *cancellable,
+                                            GError           **error)
 {
   gboolean ret = FALSE;
   guint i;
@@ -1937,7 +1949,8 @@ ostree_sysroot_write_deployments (OstreeSysroot     *self,
 
   /* And finally, cleanup of any leftover data.
    */
-  if (!ostree_sysroot_cleanup (self, cancellable, error))
+  if (!_ostree_sysroot_piecemeal_cleanup (self, cleanup_flags,
+                                          cancellable, error))
     {
       g_prefix_error (error, "Performing final cleanup: ");
       goto out;
index 1fa8e83cff1bcfa7632f0b5d4be0029f76666ff2..b2def7faaea2441d5f775bbb1312df1710ba18c1 100644 (file)
@@ -121,4 +121,10 @@ gboolean _ostree_sysroot_piecemeal_cleanup (OstreeSysroot *sysroot,
                                             GCancellable *cancellable,
                                             GError **error);
 
+gboolean _ostree_sysroot_write_deployments_internal (OstreeSysroot     *self,
+                                                     GPtrArray         *new_deployments,
+                                                     OstreeSysrootCleanupFlags cleanup_flags,
+                                                     GCancellable      *cancellable,
+                                                     GError           **error);
+
 G_END_DECLS
index 82f864cb5a2ab1ed9062ba0eb28ac2d9f7b45c56..37063e28bbcf1235d8203ad7d296e99ac907079f 100644 (file)
@@ -1591,15 +1591,11 @@ ostree_sysroot_simple_write_deployment (OstreeSysroot      *sysroot,
       added_new = TRUE;
     }
 
-  if (!ostree_sysroot_write_deployments (sysroot, new_deployments, cancellable, error))
+  if (!_ostree_sysroot_write_deployments_internal (sysroot, new_deployments,
+                                                   postclean ? OSTREE_SYSROOT_CLEANUP_ALL : 0,
+                                                   cancellable, error))
     goto out;
 
-  if (postclean)
-    {
-      if (!ostree_sysroot_cleanup (sysroot, cancellable, error))
-        goto out;
-    }
-
   ret = TRUE;
  out:
   return ret;